#pragma once


#include "Pages/EditorPageViewModel.h"
#include "EditorAudioPageModel.h"
#include "EditorAudioPageViewModel.m.h"

class RAudioPlayer;

RCLASS(ExtraHeader = "Scene/Scene.h")
class REditorAudioPageViewModel : public REditorPageViewModel 
{
    ROBJECT

public:
    void BindModel(TSharedObjectPtr<REditorPageModel> InModel) override;
    TSharedObjectPtr<RTexture2D> GetIcon() const override;
    CString GetTitle() const override;

protected:
    TSharedObjectPtr<RTexture2D> Icon;
    TWeakObjectPtr<REditorAudioPageModel> Model;


    TSharedObjectPtr<RTexture2D> PlayIcon;
    TSharedObjectPtr<RTexture2D> PauseIcon;

    TSharedObjectPtr<RTexture2D> VolumeFullIcon;
    TSharedObjectPtr<RTexture2D> VolumeMuteIcon;

    TSharedObjectPtr<RAudio> GetAudio() const;
public:

    TSharedObjectPtr<RTexture2D> GetPlayIcon() const;
    CString GetTimeText() const;
    void TogglePlay();

    float GetCurrentTimePercent() const;
    void SetCurrentTimePercent(float InPercent);

    TSharedObjectPtr<RTexture2D> GetVolumeIcon() const;

    //0-1
    float GetVolume() const;
    void SetVolume(float InVolume);
    void ToggleMute();
protected:
    
    TSharedObjectPtr<RAudioPlayer> AudioPlayer;

    float VolumeBeforeMute=1.0f;
};
